package vip.liux.front.adapter.controller.chat;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.liux.core.current.ICurrentUser;
import vip.liux.front.application.service.chat.IContactAppService;
import vip.liux.front.application.service.chat.dtos.users.ChatContactDto;
import vip.liux.front.application.service.chat.dtos.users.GetContactsInput;

import java.util.List;

@RestController
@RequestMapping("/api/chat/contact")
public class ContactController {
    private final IContactAppService contactAppService;

    private final ICurrentUser<Long> currentUser;

    public ContactController(IContactAppService contactAppService, ICurrentUser<Long> currentUser) {
        this.contactAppService = contactAppService;
        this.currentUser = currentUser;
    }

    /**
     * 获取联系人.
     *
     * @param input 输入参数
     */
    @GetMapping("/contacts")
    public List<ChatContactDto> getContacts(GetContactsInput input) {
        return contactAppService.getContacts(input, currentUser.getId());
    }

    /**
     * 获取未读消息总数.
     *
     * @return 未读消息总数
     */
    @GetMapping("/total-unread-message-count")
    public int getTotalUnreadMessageCount() {
        return contactAppService.getTotalUnreadMessageCount(currentUser.getId());
    }
}
